﻿<div id="content">
    <div class="contentTop">
        @Html.Partial("_ContentTopPartial")
    </div>

    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="@Url.Action("Index","Home")">Trang chủ</a></li>
                <li><a href="@Url.Action("Manager")">Quản lý file</a>
                </li>
            </ul>
        </div>

        
    </div>

    <!-- Main content -->
    <div class="wrapper">
        <script type="text/javascript">
            $(function () {
                var myCommands = elFinder.prototype._options.commands;
                var disabled = ['extract', 'archive', 'help', 'select'];
                $.each(disabled, function (i, cmd) {
                    (idx = $.inArray(cmd, myCommands)) !== -1 && myCommands.splice(idx, 1);
                });
                var selectedFile = null;
                var options = {
                    url: 'Index',
                    commands: myCommands,
                    lang: 'en',
                    uiOptions: {
                        toolbar: [
                            ['back', 'forward'],
                            ['reload'],
                            ['home', 'up'],
                            ['mkdir', 'mkfile', 'upload'],
                            ['open', 'download'],
                            ['info'],
                            ['quicklook'],
                            ['copy', 'cut', 'paste'],
                            ['rm'],
                            ['duplicate', 'rename', 'edit', 'resize'],
                            ['view', 'sort']
                        ]
                    },
                    handlers: {
                        select: function (event, elfinderInstance) {

                            if (event.data.selected.length == 1) {
                                var item = $('#' + event.data.selected[0]);
                                if (!item.hasClass('directory')) {
                                    selectedFile = event.data.selected[0];
                                    $('#elfinder-selectFile').show();
                                    return;
                                }
                            }
                            $('#elfinder-selectFile').hide();
                            selectedFile = null;
                        }
                    }
                };
                $('#elfinder').elfinder(options).elfinder('instance');

                $('.elfinder-toolbar:first').append('<div class="ui-widget-content ui-corner-all elfinder-buttonset" id="elfinder-selectFile" style="display:none; float:right;">' +
                    '<div class="ui-state-default elfinder-button" title="Select" style="width: 100px;"></div>');
                $('#elfinder-selectFile').click(function () {
                    if (selectedFile != null)
                        $.post('files/selectFile', { target: selectedFile }, function (response) {
                            alert(response);
                        });

                });
            });
        </script>

        <div id="elfinder" style="margin-top: 10px;"></div>
    </div>
</div>
@*@section styles
{
    @Styles.Render("~/Content/Admin/css/ui_custom.css")
    @Styles.Render("~/Content/Admin/css/elfinder.css")
}*@
@section scripts
{
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/Content/Admin/js/plugins/others/jquery.elfinder.js")

}
